<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="layout :: common_header(~{::title})">
    <title>仓位库存查询-仓库-wms仓库管理系统</title>
</head>
<body th:replace="layout :: common_body(~{::div.layui-body})">

<div class="layui-body" style="padding:15px;top: 0px;">

    <!-- start sp-wrapper -->
    <link rel="stylesheet" href="/sb/stock.css"/>
    <div class="sp-wrapper">
        <!-- <h2 class="sp-title"><span>仓位库存查询</span></h2> -->
        <div class="layui-tab layui-tab-brief" lay-filter="demo">
            <ul class="layui-tab-title">
                <!-- <li ><a href="/goods/list">商品查询</a></li> -->
                <li ><a href="/stock/spec_search">商品SKU库存查询</a></li>
                <li class="layui-this"><a href="/stock/stock_search">仓位库存查询</a></li>
                
            </ul>
        </div>
        <div class="sp-tool">

            <form action="/stock/stock_search" method="get">
                <span class="fl">
                    <b>
                        <select name="house" id="house">
                            <option selected   value="">所有仓库</option>
                            <option th:each="item:${houses}" th:value="${item.id}" th:text="${item.name}" th:if="${item.id==houseId}" selected></option>
                            <option th:each="item:${houses}" th:value="${item.id}" th:text="${item.name}" th:if="${item.id!=houseId}" ></option>
                        </select>
                    </b>
                    <b><input type="hidden"  id="sp-category">
                    <b><input type="text" name="str" id="str" placeholder="输入仓位编码查询" th:value="${locationNum}" style="width: 200px;"></b>
                    <input type="submit" class="button" value="查询" />
                        <b>总共：&nbsp;[[${totalSize}]]&nbsp;条记录</b>
                    <input type="submit" class="button" id="export" value="导出" />
                </span>
            </form>

            <span class="fr">
<!--                <i>导出系统库存</i>-->
<!--                <i>生成盘点单据</i>-->
            </span>
        </div>
        <div class="sp-table" >
            <table>
                <thead>
                <tr>
                    <th>ID</th>
                    <th>仓位编码</th>
                    <th>商品名称</th>
                    <th>sku编码</th>
                    <th>商品规格</th>
                    <th>仓位库存</th>
<!--                    <th>盘点库存</th>-->
<!--                    <th>盘点盈亏</th>-->
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="StockVo,item:${lists}">
                    <td th:text="${StockVo.id}"></td>
                    <td th:text="${StockVo.locationNumber}">10000</td>
                    <td th:text="${StockVo.getGoodsName()}">新款连衣裙2019</td>
                    <td th:text="${StockVo.getSpecNumber()}">10000-01</td>
                    <td >
                        <span th:text="${StockVo.colorValue}"></span>&nbsp;
                        <span th:text="${StockVo.sizeValue}"></span>&nbsp;
                        <span th:text="${StockVo.styleValue}"></span>&nbsp;
                    </td>

                    <td >
                        当前库存：<span th:text="${StockVo.getCurrentQty()}"></span><br />
                        锁定库存：<span th:text="${StockVo.lockedQty}"></span><br />
                    </td>
<!--                    <td><input type="text" placeholder="这里是输入框"></td>-->
<!--                    <td></td>-->
                    <td>
                        <i class="clean_up" th:attr="data-id=${StockVo.id},currentQty=${StockVo.getCurrentQty()}">腾空仓位</i>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="pages">
            <paging:pager th:value="${pageIndex}" th:rows="${totalSize}" th:size="${pageSize}"/>
        </div>

    </div>

    <script type="text/javascript" src="/sb/jquery.min.js"></script>
    <script type="text/javascript" src="/sb/Tips.min.js"></script>
    <script type="text/javascript">
        $(function () {

            $(".clean_up").click(function () {
                var dataId = $(this).attr("data-id");
                // alert(dataId);
                var currentQty = $(this).attr('currentQty');
                // alert(currentQty);
       /*         if(currentQty!=0){
                    alert("还有库存，不能腾空");
                }else{*/
                    //AJAX 腾空仓位
                    $.ajax({
                        url: '/stock/stock_search_clean_up',
                        type: "POST",
                        dataType: 'json',
                        contentType: 'application/json',
                        data:JSON.stringify({id:dataId}),
                        success: function (res) {
                            if(res.code == 0){
                                alert("腾空成功");
                                window.location.reload();
                            }else{
                                alert(res.msg);
                            }
                        }
                    });
                //}
            })

            $("#export").click(function () {
                var urlLink = window.location.href;
                var exportLink;
                if ($('#str').val()==""&&$('#house').val()=="") {
                     exportLink = urlLink .split("/stock/stock_search")[0];
                }else {
                     exportLink = urlLink .split("/stock/stock_search?house="+$('#house').val()+"&str="+$('#str').val())[0];
                }

                exportLink += "/stock/export?str="+$('#str').val()+"&house="+$('#house').val();
                window.open(exportLink);
            });

        });
    </script>
    <!-- end sp-wrapper -->

</div>
</body>
<html>
